package bianlifeng;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author xizizzz
 * @description: TODO
 * @date 2021-9-1下午 05:08
 */
public class Test1 {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        final String[] split = str.split(",");
        int[] arr = new int[split.length];
        for (int i = 0; i < split.length; i++) {
            arr[i] = Integer.parseInt(split[i]);
        }
        //1 1 2 2 3 7
        //1 2 3 4 5 7
        Arrays.sort(arr);
        int res = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            int temp = arr[i];
            while (arr[i + 1] <= temp) {
                arr[i + 1]++;
                res++;
            }
        }
        System.out.println(res);
    }
}
